/*
 * Copyright 2012 Alain Pannetrat (L1L1@gmx.com)
 * 
 * This file is part of cookie-miner.
 * 
 * cookie-miner is free software: you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation, either version 3 of the License, or 
 * (at your option) any later version.
 * 
 * cookie-miner is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License 
 * along with cookie-miner. If not, see http://www.gnu.org/licenses/.
 *
 * @version: $Id$
 *
 */
#include "common.h"
#include "log_facility.h"



bool trim_eol(std::string &s)
{
        size_t pos = s.find_first_of("\r\n");

        if (pos==s.npos)
        {
                return false;
        }

        s.erase(pos,s.npos);
        return true;
}

bool split_lr(std::string& left, std::string& right, const char *sep, const std::string& str)
{
	std::string s(str);
	size_t pos = s.find(sep);

	if (pos==std::string::npos) return false;
	
	left  = s.substr(0,pos);
	right = s.substr(pos+strlen(sep));

	return true;
}

size_t strlcpy(char *dst, const char *src, size_t n)
{
    strncpy(dst,src,n-1);
    dst[n-1]=0;
    return strlen(src);
}


